import React, { Fragment } from 'react'
import PropTypes from 'prop-types'
import { View, Text } from 'react-native'
import BlurImg from 'src/components/blur-img'
import CustomImage from 'src/components/image/CustomImage'
import CustomButton from 'src/components/button/CustomButton'
import styles from '../css/CompanyHeaderCss'
import { ImageHost } from 'src/config/index'
import { companyBgColoList, companyDefaultLogo } from 'src/utils/ConfigUtil'
import LinearGradient from 'react-native-linear-gradient'
import { showTipModal } from 'src/utils/ModalUtil'
export default class CompanyHeader extends React.PureComponent {
  static propTypes = {
    data: PropTypes.object,
    companyClick: PropTypes.func,
    jumpBCompanyNameSample: PropTypes.func,
    companyId: PropTypes.number,
    jumpCompanyAvator: PropTypes.func,
    masterCompanyPress: PropTypes.func,
    slaveCompanyPress: PropTypes.func
  }

  render () {
    const { data, jumpBCompanyNameSample, jumpCompanyAvator, masterCompanyPress, slaveCompanyPress } = this.props
    return (
      <BlurImg blurAmount={0} style={styles.container} source={require('src/imgC/company/company-bg.png')}>
        <LinearGradient colors={['rgba(0,0,0,0.2)', 'rgba(0,0,0,0.5)', 'rgba(0,0,0,0.9)']} style={styles.bgColor}>
        </LinearGradient>
        <View style={styles.contentWrap}>
          <View style={styles.titleWrap}>
            <View style={styles.firstWrap}>
              <CustomButton onPress={jumpBCompanyNameSample} params={{ data }} style={styles.simpleNameBtn}>
                <Text numberOfLines={1} style={styles.simpleName}>{data.simpleName || '请填写简称'}</Text>
              </CustomButton>
              {!!data.famousId && <Fragment>
                <LinearGradient
                  colors={['#FF9310', '#FFDC25']}
                  style={styles.famousWrap}>
                  <Text style={styles.famousText}>名企</Text>
                </LinearGradient>
                {data.isMaster && <CustomButton style={[styles.famousType]} onPress={masterCompanyPress}>
                  <Text style={[styles.famousTypeText]}>主管企业</Text>
                  <CustomButton style={styles.famousQuestionWrap} onPress={masterCompanyPress}>
                    <Text style={styles.famousQuestion}>?</Text>
                  </CustomButton>
                </CustomButton>}
                {!data.isMaster && <CustomButton style={[styles.famousType, { backgroundColor: '#F0F0F0' }]} onPress={slaveCompanyPress}>
                  <Text style={[styles.famousTypeText, { color: '#999999' }]}>关联企业</Text>
                  <CustomButton style={styles.famousQuestionWrap} onPress={slaveCompanyPress}>
                    <Text style={styles.famousQuestion}>?</Text>
                  </CustomButton>
                </CustomButton>}
              </Fragment> }
            </View>
            <Text style={styles.companyName}>{data.companyName || ''}</Text>
          </View>
          <CustomButton onPress={jumpCompanyAvator} params={{ name: data.simpleName || data.companyName || '', uri: data.companyLogo }} style={styles.imgShadow}>
            <CustomImage style={styles.logo} source={data.companyLogo ? { uri: data.companyLogo } : companyDefaultLogo} />
          </CustomButton>
        </View>
      </BlurImg >
    )
  }
}
